﻿Imports System
Imports System.Collections
Imports System.Configuration
Imports System.Data
Imports System.Linq
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.HtmlControls
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Xml.Linq
Imports BBDD
Imports Controladores

 _

Class ingresarEfectivo
   Inherits System.Web.UI.Page

   Protected Sub Page_Load(sender As Object, e As EventArgs)
      
      If Session("privUser") Is Nothing Or Integer.Parse(Session("privUser").ToString()) < 1 Then
         Response.Redirect("index.aspx")
      Else
         If Integer.Parse(Session("privUser").ToString()) = 1 Then
            Me.campoDNIIngresar.Text = Session("DNIUser").ToString()
            Me.campoDNIIngresar.Enabled = False
         End If
      End If 
   End Sub 'Page_Load
    
   
   
   Protected Sub boton_ingresar_Click(sender As Object, e As EventArgs)
      
      If Consultas.existeUsuario(campoDNIIngresar.Text.ToString()) Then
         Session("error") = controlador.ingresarEfectivo(campoDNIIngresar.Text.ToString(), Integer.Parse(cantidadAIngresar.Text.ToString()))
         If Session("error").ToString() = "" Then
            Me.campoDNIIngresar.Enabled = True
            controlador.CreateMessageAlert(Me, "Dinero ingresado correctamente", "Operacion Satisfactoria")
            Me.campoDNIIngresar.Text = ""
            Me.cantidadAIngresar.Text = ""
         Else
            controlador.CreateMessageAlert(Me, Session("error").ToString(), "Mensaje de error")
         End If
      Else
         Session("error") = "No existe tal usuario"
         controlador.CreateMessageAlert(Me, Session("error").ToString(), "Mensaje de error")
      End If
   End Sub 'boton_ingresar_Click 
End Class 'ingresarEfectivo
